﻿using System;
namespace Producers.Kis.Xtee.Riik.Ee.Producer.Kis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="PetitionerConfirmation", Namespace="http://producers.kis.xtee.riik.ee/producer/kis", Target=typeof(PetitionerConfirmation))]
    public class PetitionerConfirmationSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IPetitionerConfirmation clazz;
        
        public PetitionerConfirmationSerializer(IPetitionerConfirmation clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.ConfirmationCourt!=null) {
                Writer.WriteStartElement("ConfirmationCourt");
                Writer.WriteTypeAttribute("http://producers.kis.xtee.riik.ee/producer/kis", "ConfirmationCourt");
                Writer.WriteString(clazz.ConfirmationCourt.ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("ClaimProceedings");
            if (clazz.ClaimProceedings!=null) {
                Writer.WriteTypeAttribute("http://producers.kis.xtee.riik.ee/producer/kis", "ClaimProceedings");
                Writer.WriteString(clazz.ClaimProceedings.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ClaimProceedings");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ConfirmationCourt") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>PetitionerConfirmation>ConfirmationCourt");
                }
                clazz.ConfirmationCourt = new global::Producers.Kis.Xtee.Riik.Ee.Producer.Kis.ConfirmationCourt(Reader.ReadElementString("ConfirmationCourt"));
            }
            if (Reader.LocalName=="ClaimProceedings") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>PetitionerConfirmation>ClaimProceedings");
                }
                clazz.ClaimProceedings = new global::Producers.Kis.Xtee.Riik.Ee.Producer.Kis.ClaimProceedings(Reader.ReadElementString("ClaimProceedings"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>PetitionerConfirmation>ClaimProceedings", Reader.LocalName);
            }
        }
    }
}
